package org.xiaoyu.rpc.registry.nacos;

import com.alibaba.nacos.api.NacosFactory;
import org.xiaoyu.rpc.registry.Discover;
import org.xiaoyu.rpc.registry.DiscoverFactory;

import java.util.Properties;

/**
 * Created By Have
 * 2021/7/13 16:15
 */
public class NacosDiscoverFactory implements DiscoverFactory {

    @Override
    public Discover createDiscover(Properties properties) {
        try {
            return new NacosDiscover(new NacosNamingServiceWrapper(NacosFactory.createNamingService(properties.getProperty("registerAddr"))));
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}
